package com.hpf.lease.web.admin.controller;

import com.hpf.lease.common.result.Result;
import com.hpf.lease.model.bean.PaymentType;
import com.hpf.lease.web.admin.service.PaymentTypeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "支付方式管理模块")
@RestController
@RequestMapping("/admin/payment")
public class PaymentTypeController {
    @Resource
    PaymentTypeService service;

    @GetMapping("/list")
    @Operation(summary = "查询所有支付方式")
    public Result<List<PaymentType>> listAll(){
        List<PaymentType> list = service.list();
        return Result.ok(list);
    }

    @PostMapping("/saveOrUpdate")
    @Operation(summary = "根据id保存或更新支付方式")
    public Result<Object> saveOrUpdate(@RequestBody PaymentType paymentType){
        boolean b = service.saveOrUpdatePaymentType(paymentType);
        return Result.build(b);
    }
    @DeleteMapping("/deleteById/{id}")
    @Operation(summary = "根据id逻辑删除支付方式")
    public Result<Object> deleteById(@PathVariable Integer id){
        return Result.build(service.removeById(id));
    }

}

